
#include"pl.h"
#include"dimacsFile.h"
#include"vertexOrders.h"
#include"bitMapGraph.h"
#include<stdio.h>

int n;
int m;
extern long set;
extern long sets;
extern long violates;
extern double violates2;
extern double violates22;
extern double limcut;
FILE *out, *file;
char* testeIn[100];
char* testeOut[100];

int numT = 15;
int main(){

testeIn[0]= "instance/anna2.col";
testeOut[0] = "Result/annaOut.txt";
testeIn[1]= "instance/david2.col";
testeOut[1] = "Result/davidOut.txt";
testeIn[2]= "instance/games1202.col";
testeOut[2] = "Result/games120Out.txt";
testeIn[3]= "instance/huck2.col";
testeOut[3] = "Result/huckOut.txt";
testeIn[4]= "instance/myciel32.col";
testeOut[4] = "Result/myciel3Out.txt";
testeIn[5]= "instance/myciel42.col";
testeOut[5] = "Result/myciel4Out.txt";
testeIn[6]= "instance/myciel52.col";
testeOut[6] = "Result/myciel5Out.txt";
testeIn[7]= "instance/myciel62.col";
testeOut[7] = "Result/myciel6Out.txt";
testeIn[8]= "instance/myciel72.col";
testeOut[8] = "Result/myciel7Out.txt";
testeIn[9]= "instance/queen5_52.col";
testeOut[9] = "Result/queen5_5Out.txt";
testeIn[10]= "instance/queen6_62.col";
testeOut[10] = "Result/queen6_6Out.txt";
testeIn[11]= "instance/anna2.col";
testeOut[11] = "Result/annaOut.txt";
testeIn[12]= "instance/queen8_82.col";
testeOut[12] = "Result/queen8_8Out.txt";
testeIn[13]= "instance/miles2502.col";
testeOut[13] = "Result/miles250.col.txt";
testeIn[14]= "instance/queen9_92.col";
testeOut[14] = "Result/queen9_9Out.txt";
testeIn[15]= "instance/miles5002.col";
testeOut[15] = "Result/miles500.col.txt";
	double value;
	int f = 0;
	for(f = 0; f <= numT; f++){
		file= fopen(testeIn[f], "r");
		int i,j;
		out= fopen(testeOut[f],"w");
		if(!readFile(file, complement, &n, &m)){
	   	    printf(" numero de vertices %d \n", n);
			printf(" numero de arestas %d \n", m);
			int* c = malloc(sizeof(int)*n);
			mcrStableSort(n, c);
			if((makePL(n,m)==0)&&(solvePL()==0)&&(getValues()==0)){
				fprintf(out,"\nvalores dos pesos\n");
			    	for(i =0; i< n; i++){
			    		for(j=0; j<n;j++){
			    			if(weigths[va[i]][va[j]] > 0.0)fprintf(out,"\n valor: %f para X(%lu ,%lu ) \n", weigths[va[i]][va[j]],va[i]+1,va[j]+1);
					 }
			    	}
				fprintf(out,"Valores dos vertices\n");
				int i;		
				for(i=0; i<n; i++){
					fprintf(out,"Vertice %lu vale %f \n",va[i], weigths[va[i]][va[i]]);
					value += weigths[va[i]][va[i]];
				}	
				fprintf(out,"\n Valor da solução otima: %f", value);
			violatedSets(n);
				printf("\nConjuntos Violados: %lu\n ",violates);
				printf("\nConjuntos Gerados: %lu\n ",set);
				printf("\nConjuntos Violados: %lu\n ",violates);
				printf("\nConjuntos Gerados: %lu\n ",set);
		}
		fclose(out);
		fclose(file);
	}
}
	return 0;
}
